﻿<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="reportSend.aspx.cs" Inherits="famails.BackEnd.page.reportSend" MasterPageFile="~/Master.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div style="width: 100%; padding: 10px;">

        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="border: 1px solid #333; padding: 0px; margin-bottom: 10px;">
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px 20px; background: #000; color: #fff; font-size: 18px; font-weight: bold; position: relative;">
                Thống kê tổng quát
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12">
                <asp:Panel Visible="false" ID="pnError" runat="server">
                    <div class="error-box round" style="padding:10px">
                        <asp:Label ID="lblError" runat="server" Text=""></asp:Label>
                    </div>
                </asp:Panel>
                <asp:Panel Visible="false" ID="pnSuccess" runat="server">
                    <div class="confirmation-box round" style="padding:10px;"> 
                        <asp:Label ID="lblSuccess" runat="server" Text=""></asp:Label>
                    </div>
                </asp:Panel>
            </div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 0px;">
                    <asp:Panel ID="pnReport" runat="server">
                        <div style="border-bottom:1px solid #333;padding:0px 10px;">
                            <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height:100%;padding: 0px;margin: 10px 0px;border:1px solid #dedede;">
                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto;padding:10px 5px;text-align:center;background:#f9f9f9;">
                                    <asp:Label ID="lblCampianName" style="font-size:16px;line-height:20px;color:#333;font-weight:bold;" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;">
                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto;padding:10px 5px;">
                                            Email gửi : 
                                    </div>
                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto;min-height:35px;padding:10px 5px;">
                                        <asp:Label ID="lblEmailSend" runat="server" Text="Không hiển thị "></asp:Label>
                                    </div>
                                </div>
                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;background:#f9f9f9;">
                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto;padding:10px 5px;">
                                            Nhóm email nhận : 
                                    </div>
                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto;min-height:35px;padding:10px 5px;">
                                        <asp:Label ID="lblGroupEmailTo" runat="server" Text="Không hiển thị"></asp:Label>
                                    </div>
                                </div>
                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;">
                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto;padding:10px 5px;">
                                            Thời gian gửi : 
                                    </div>
                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto;min-height:35px;padding:10px 5px;">
                                         <asp:Label ID="lblDateStart" runat="server" Text="Không hiển thị "></asp:Label>
                                    </div>
                                </div>
                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;background:#f9f9f9;">
                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto;padding:10px 5px;">
                                            Kết thúc : 
                                    </div>
                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto;min-height:35px;padding:10px 5px;">
                                        <asp:Label ID="lblDateEnd" runat="server" Text="Không hiển thị "></asp:Label>
                                    </div>
                                </div>
                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;">
                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto;padding:10px 5px;">
                                            Số email gửi : 
                                    </div>
                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto;min-height:35px;padding:10px 5px;">
                                        <asp:Label ID="lblTotalMailSend" runat="server" Text="Không hiển thị"></asp:Label>
                                    </div>
                                </div>
                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;background:#f9f9f9;">
                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto;padding:10px 5px;">
                                            Số email đã mở : 
                                    </div>
                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto;min-height:35px;padding:10px 5px;">
                                        <asp:Label ID="lblOpened" runat="server" Text="Không hiển thị"></asp:Label>
                                    </div>
                                </div>
                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;">
                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto;padding:10px 5px;">
                                            Số email chưa mở : 
                                    </div>
                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto;min-height:35px;padding:10px 5px;">
                                        <asp:Label ID="lblNotOpen2" runat="server" Text="Không hiển thị"></asp:Label>
                                    </div>
                                </div>
                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;background:#f9f9f9;">
                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto;padding:10px 5px;">
                                            Số email click : 
                                    </div>
                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto;min-height:35px;padding:10px 5px;">
                                        <asp:Label ID="lblClick" runat="server" Text="Không hiển thị"></asp:Label>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height: 100%;padding:10px 10px;">
                                <asp:Label ID="lblChart" runat="server" Text="Không có dữ liệu"></asp:Label>
                                <%--<div id="chart_div" style="width: 100%; height: 270px;"></div>--%>
                            </div>
                        </div>
                    </asp:Panel>
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto;padding:0px;background:#333;">
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto;padding:10px;">
                   <label for="simple-input" style="float:left;padding:10px 20px 0px 0px;font-weight: bolder;font-size:20px;color:#fff; text-transform: none">
                    Danh sách email đã đọc</label>
                </div>
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto;padding:10px;">
                    <div id="btnExportExcel_open" style="float:right;margin-right:10px;background:#333;color:#fff;text-align:center;padding:6px 15px;border-radius:0px;border:1px solid #fff;" class="btn">
                        <span style="margin-right:10px;" class="fa fa-mail-forward"></span> Xuất dữ liệu
                    </div>
                </div> 
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;">
                    <div id='jqxWidget' style="width:100% !important;font-size: 13px; font-family: Verdana; float: left;">
                        <div id="jqxgrid_open" style="width:100% !important;">
                        </div>
                        <div id="paginginfo_open" style="width:100% !important;">
                        </div>
                    </div>
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto;padding:0px;background:#333;">
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto;padding:10px;">
                   <label for="simple-input" style="float:left;padding:10px 20px 0px 0px;font-weight: bolder;font-size:20px;color:#fff; text-transform: none">
                    Danh sách email gửi lỗi</label>
                </div>
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto;padding:10px;">
                    <div id="btnExportExcel_error" style="float:right;margin-right:10px;background:#333;color:#fff;text-align:center;padding:6px 15px;border-radius:0px;border:1px solid #fff;" class="btn">
                        <span style="margin-right:10px;" class="fa fa-mail-forward"></span> Xuất dữ liệu
                    </div>
                </div> 
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;">
                    <div id='jqxWidget_error' style="width:100% !important;font-size: 13px; font-family: Verdana; float: left;">
                        <div id="jqxgrid_error" style="width:100% !important;">
                        </div>
                    </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function getQueryStrings() {
            var assoc = {};
            var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
            var queryString = location.search.substring(1);
            var keyValues = queryString.split('&');

            for (var i in keyValues) {
                var key = keyValues[i].split('=');
                if (key.length > 1) {
                    assoc[decode(key[0])] = decode(key[1]);
                }
            }

            return assoc;
        }
        jQuery(function ($) {
            $("#btnExportExcel_error").click(function () {
                $("#jqxgrid_error").jqxGrid('exportdata', 'xls', 'erroremaillist');
            });
            $("#btnExportExcel_open").click(function () {
                $("#jqxgrid_open").jqxGrid('exportdata', 'xls', 'openemaillist');
            });
            var qs = getQueryStrings();
            var id = qs["id"];
            //alert(id);
            $("#jqxgrid_open").jqxGrid('showloadelement');
            $("#jqxgrid_error").jqxGrid('showloadelement');
            var postValue = "{id:" + id + "}";
            $.ajax({
                type: "POST",
                url: "ReportSend.aspx/ErrorMailList",
                data: postValue,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var source =
            {
                datatype: "json",
                datafields: [
                    { name: 'ID', type: 'decimal' },
                      { name: 'Message', type: 'string' },
                      { name: 'To', type: 'string' },
                      { name: 'Status', type: 'string' },
                    { name: 'SendTime', type: 'date' }
                ],
                id: 'ID',
                localdata: data,
                pager: function (pagenum, pagesize, oldpagenum) {
                }
            };
                    var dataAdapter = new $.jqx.dataAdapter(source);
                    $("#jqxgrid_error").jqxGrid(
                    {
                        width: $('#jqxWidget').width(),
                        source: dataAdapter,
                        selectionmode: 'multiplerowsextended',
                        sortable: true,
                        pageable: true,
                        autoheight: true,
                        columnsresize: true,
                        columns: [
                          { text: 'Email', datafield: 'To' },
                          { text: 'Thời gian gửi', datafield: 'SendTime', cellsalign: 'center', cellsformat: 'dd/MM/yyyy HH:mm:ss' },
                          { text: 'Tình trạng', datafield: 'Status', cellsformat: 'F2' },
                          { text: 'Mô tả', datafield: 'Message' }
                        ]
                    });

                }
            });


            $.ajax({
                type: "POST",
                url: "ReportSend.aspx/OpenMailList",
                data: postValue,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var source =
            {
                datatype: "json",
                datafields: [
                    { name: 'ID', type: 'decimal' },
                      { name: 'To', type: 'string' },
                      { name: 'OpenTime', type: 'date' },
                    { name: 'SendTime', type: 'date' }
                ],
                id: 'ID',
                localdata: data,
                pager: function (pagenum, pagesize, oldpagenum) {
                }
            };
                    var dataAdapter = new $.jqx.dataAdapter(source);
                    $("#jqxgrid_open").jqxGrid(
                    {
                        width: $('#jqxWidget').width(),
                        source: dataAdapter,
                        selectionmode: 'multiplerowsextended',
                        sortable: true,
                        pageable: true,
                        autoheight: true,
                        columnsresize: true,
                        columns: [
                          { text: 'Email', datafield: 'To'},
                          { text: 'Thời gian gửi', datafield: 'SendTime', cellsalign: 'center', cellsformat: 'dd/MM/yyyy HH:mm:ss' },
                          { text: 'Thời gian mở', datafield: 'OpenTime', cellsalign: 'center', cellsformat: 'dd/MM/yyyy HH:mm:ss' }
                        ]
                    });

                }
            });
        });
    </script>
</asp:Content>
